﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.WebControls;
using CreditAgricole.Framework;

namespace CreditAgricole.PageCodeBehind
{
    public class ContextPage : PublishingLayoutPage
    {
        protected new IMasterPage Master
        {
            get { return (IMasterPage)base.Master; }
        }

        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            string siteUrl = SPContext.Current.Site.Url;
            string webUrl = SPContext.Current.Web.Url;
            string serverRelativeUrl = SPContext.Current.Site.ServerRelativeUrl;
            if (serverRelativeUrl == "/")
            {
                this.MasterPageFile = string.Format("/_catalogs/masterpage/{0}", Constants.MasterpagetName);
            }
            else
            {
                this.MasterPageFile = string.Format("{0}/_catalogs/masterpage/{1}", serverRelativeUrl, Constants.MasterpagetName);
            }
        }

        public void SelectMenuItem(Constants.ElementsSiteMenu oMenuItem)
        {
            Master.SelectMenuItem(oMenuItem);
        }
    }
}
